package com.sgzn.sgpay.enums;

import lombok.Getter;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by linliangfang 13580393408
 * DATETIME:2018/6/5 16:02
 * Description:
 */
public enum EnumBankCode {

    GSYH("1002", "工商银行"),
    NYYH("1005", "农业银行"),
    ZGYH("1026", "中国银行"),
    JSYH("1003", "建设银行"),
    ZSYH("1001", "招商银行"),
    YCYH("1066", "邮储银行"),
    JTYH("1020", "交通银行"),
    PFYH("1004", "浦发银行"),
    MSYH("1006", "民生银行"),
    XYYH("1009", "兴业银行"),
    PAYH("1010", "平安银行"),
    ZXYH("1021", "中信银行"),
    HXYH("1025", "华夏银行"),
    GFYH("1027", "广发银行"),
    GDYH("1022", "光大银行"),
    BJYH("1032", "北京银行"),
    NBYH("1056", "宁波银行");

    @Getter
    private String code;
    @Getter
    private String bankName;

    //构造函数
    EnumBankCode(String code, String desc) {
        this.code = code;
        this.bankName = desc;
    }

    private static final Map<String, String> map = new HashMap<String, String>();

    static{
        for(EnumBankCode single : EnumBankCode.values()){
            map.put(single.code, single.bankName);
        }
    }

    /**
     * 根据编码码获取类型
     * @param code
     * @return
     */
    public static String getDescByCode(String code) {
        if(isContain(code)){
            return map.get(code);
        }
        return code+"未定义";
    }

    public static boolean isContain(String code){
        if(map.containsKey(code)){
            return true;
        }
        return false;
    }
}
